package com.yinxin.reflection.InvocationProxy.Jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author yinxin
 * @version 1.0
 * @Description:
 * @date 2022/8/1816:33
 */

public class JDKProxy implements InvocationHandler {
   private Object object;
   public JDKProxy(Object object) {
      this.object = object;
   }
   // 创建代理对象
   public  Object createProxy() {
      Object o = Proxy.newProxyInstance(object.getClass().getClassLoader()
              ,object.getClass().getInterfaces(),this);
      return o;
   }

   @Override
   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      System.out.println("*********当前时间->xxx");
      method.invoke(object, args);
      return null;
   }

}
